<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8"/>
        <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
        <meta http-equiv="X-UA-Compatible" content="ie=edge"/>
        <title>Document</title>
        <script src = 'jquery-1.10.1.min.js'></script>
        <script>
            /* 
                parent()  获取父节点
                parents() 获取父节点们  参数选择器
                closest() 必须传入参数，参数也是选择器，只获取第一个符合条件的元素，从自己开始去查找的
             */
             $(function(){
                // $("#div2").parent().css("backgroundColor", 'red');

                // $("#div2").parents(".box").css("backgroundColor", 'red');
                $("#div2").closest("#div1").css("backgroundColor", 'red');
             })
        </script>
    </head>
    <body class = 'box'>
        <div id = 'div1' class = 'box'>
            div1
            <div id = 'div2' class = 'box'>
                div2
            </div>
        </div>
    </body>
</html>